<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="com.tjtt.tdm.base.PubMethod" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">   
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">   								
	<head> 
	    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />							
		<%@ include file="../jslib/jquerylib.jsp" %>
	    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
	    
        <link href="<%=request.getContextPath() %>/web/style/layout.css" type="text/css" rel="stylesheet"/>
        <link rel="stylesheet" href="<%=request.getContextPath() %>/jslib/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css"/>
        <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/ztree/jquery.ztree.core-3.4.js"></script>
        <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
        <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/demo.css">
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
	       <!-- 删除结果信息返回 -->
	    	<c:if test="${requestScope.message!=null}">
				<script type="text/javascript">
	  	 		     alert('<c:out value="${requestScope.message}"></c:out>');
	  	 		     window.close();
	  			</script>
	        </c:if>
	 
	<script type="text/javascript">
	var mobanid = '';
	var ids = '';
	var W;
	var formId='';
	var isChild=false;
	var isXLJC=false;
	var api = frameElement.api;

	if (api!=undefined){
		W = api.opener;
	}
	$(document).ready(function(){
			formId=${requestScope.formid};
			isChild=${requestScope.isChild};
			isXLJC=${requestScope.isXljc};
			$("#gridTable").jqGrid({					
					url:'<%=request.getContextPath() %>/auto!queryAutoDataQuery.action?formid='+${requestScope.formid}+'&owner=${requestScope.owner}&isXLJC=${requestScope.isXljc}&pipelineno=${requestScope.pipelineno}&byTableValue=${requestScope.byTableValue}&byTableColumn=${requestScope.byTableColumn}&sbtype=${requestScope.sbtype}&columnguolvsql='+encodeURIComponent('${requestScope.columnguolvsql}')+'&temp='+Math.round(Math.random()*10000),
					datatype: "json",
					//height: document.documentElement.clientHeight-240,
					height: 180,
					width: '1020', 
					//autowidth:true,
					colNames:[${requestScope.colName}],
					colModel:[${requestScope.colModel}],
					shrinkToFit:false,
					sortname:'ID',
					sortorder:'asc',
					viewrecords:true,
					multiselect: true, // 是否显示复选框
					multiboxonly : true, 
					//gridview: true,  //提升速度
					rownumbers: true,//显示行号
					rownumWidth: 30, //行号的宽度
					rowNum:<%=session.getAttribute("SYS_PAGECOUNT")%>,
					rowList:[15,20,50,200,500],
					toolbar: [false,"top"],
					jsonReader: {
						root:"rows",		// 数据行（默认为：rows）
						page: "page",  	// 当前页
						total: "total",  // 总页数
						records: "records",  // 总记录数
						repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
					},
					prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
					pager:"#gridPager",
					postData : {
		     			columns : "${requestScope.columns}",
		     			tableName:"${formnew.formEnName}"
		     		},
					caption: "${formnew.formCnName}列表"									
			});
				
	}); 
	//添加
	function addItem(){
		var toUrl = '<%=request.getContextPath() %>/auto!gotoAdd.action?formid=${requestScope.formid}&fromtype=flow&byTableValue=${requestScope.byTableValue}&byTableColumn=${requestScope.byTableColumn}';
		//var temp =window.showModalDialog(toUrl,null,"dialogWidth="+${formWidth}+"px;dialogHeight="+${formHeight}+"px;");
		
		$.dialog({
	        title: '${formnew.formCnName}添加页面',
	        //content: 'url:<%=request.getContextPath() %>/auto!gotoAdd.action?formid=${requestScope.formid}&fromtype=flow&byTableValue=${requestScope.byTableValue}&byTableColumn=${requestScope.byTableColumn}',-->
	        content: 'url:'+ toUrl,
			okVal: false,//确定按钮文字
	        cancelVal: false,//取消按钮文字
	        min: true, //是否显示最小化按钮
	        max: false,//是否显示最大化按钮
	        fixed: false,//开启静止定位
	        lock: true,//开启锁屏
	        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
	        time: null,//设置对话框显示时间
	        resize: true,//是否允许用户调节尺寸
	        drag: true,//是否允许用户拖动位置
	        cache: false,//是否缓存iframe方式加载的窗口内容页
	        zIndex:W==null?1976:W.$.dialog.setting.zIndex+1,
	        width: ${formWidth},
	        height: ${formHeight},
	        close: function(){
	        	gridSearch();
		    }
		});
	}
	
	//编辑字段
	function updateItem(){
		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		if(ids.indexOf(",")!=-1){
			  alert("只能选择一条记录!");  
		        return false; 
		}
		var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
		var id = row.ID;
		var toUrl = '<%=request.getContextPath() %>/auto!gotoUpdate.action?formid=${requestScope.formid}&id='+id+'&byTableValue=${requestScope.byTableValue}&byTableColumn=${requestScope.byTableColumn}';
		//var temp =window.showModalDialog(toUrl,null,"dialogWidth="+${formWidth}+"px;dialogHeight="+${formHeight}+"px;");
		gridSearch();
		$.dialog({
	        title: '${formnew.formCnName}修改页面',
	       // content: 'url:<%=request.getContextPath() %>/auto!gotoUpdate.action?formid=${requestScope.formid}&id='+id+'&byTableValue=${requestScope.byTableValue}&byTableColumn=${requestScope.byTableColumn}',-->
	        content: 'url:'+ toUrl,
	        okVal: false,//确定按钮文字-->
	        cancelVal: false,//取消按钮文字-->
	        min: true, //是否显示最小化按钮-->
	        max: false,//是否显示最大化按钮-->
	        fixed: false,//开启静止定位-->
	        lock: true,//开启锁屏-->
	        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）-->
	        time: null,//设置对话框显示时间-->
	        resize: true,//是否允许用户调节尺寸-->
	        drag: true,//是否允许用户拖动位置-->
	        cache: false,//是否缓存iframe方式加载的窗口内容页
	        width: ${formWidth},
	        height: ${formHeight},
	        zIndex:W==null?1976:W.$.dialog.setting.zIndex+1,
	        close: function(){
	        	gridSearch();
		    }
		});
	  }
	  //删除模板专用方法
	  
	  function deleteMuBan(){
		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		strs=ids.split(","); //字符分割
		for(var i=0; i<strs.length; i++){ 
			var id=strs[i];
			var row = jQuery("#gridTable").jqGrid('getRowData',id);//获取选中行.
			var state = row.SHENHESTATE;
			var s = state.indexOf("审核通过"); 
			if(s!=-1){
				alert("含有审核通过的数据，不允许删除!");  
			    return false;
			}
		}

		if(!confirm("是否确认删除？")){
			return false;
		}
		
		var params = {
					"id": ids
		};  
		var actionUrl = "<%=request.getContextPath() %>/item!deleteMuBan.action"; 
		$.ajax({  
			  url : actionUrl,  
		      type : "post", 
		      data : params,  
		      dataType : "json",  
		      cache : false,  
		      error : function(textStatus, errorThrown) {  
		          alert("系统ajax交互错误: " + textStatus.value);  
		      },  
		      success : function(data, textStatus) {
		      	if(data.ajaxResult=='success'){
		      		alert("删除成功！");       
		      		gridSearch();    
		      	}else{
		      		alert("删除失败！");
		      	}
		    }  
		});
	}
	//delete
	function deleteItem(){
		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		if(!confirm("是否确认删除？")){
			return false;
		}

		var params = {
					"ids": ids,
					"formId":formId,
					"tableName":"${formnew.formEnName}"
					};  
		var actionUrl = "<%=request.getContextPath() %>/auto!deleteForm.action";  
		$.ajax({  
			  url : actionUrl,  
		      type : "post", 
		      data : params,  
		      dataType : "json",  
		      cache : false,  
		      error : function(textStatus, errorThrown) {  
		          alert("系统ajax交互错误: " + textStatus.value);  
		      },  
		      success : function(data, textStatus) {
		      	if(data.result=='success'){
		      		alert("删除成功！");       
		      		gridSearch();    
		      	}else{
		      		alert("删除失败！");
		      	}
		    }  
		});
	}
	
	//查看表单
	function viewItem(){
		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		if(ids.indexOf(",")!=-1){
			  alert("只能选择一条记录!");  
		        return false; 
		}
		var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
		var id = row.ID;
		var toUrl = '<%=request.getContextPath() %>/auto!gotoView.action?formid=${requestScope.formid}&id='+id+'&byTableValue=${requestScope.byTableValue}&byTableColumn=${requestScope.byTableColumn}';
		//var temp =window.showModalDialog(toUrl,null,"dialogWidth="+${formWidth}+"px;dialogHeight="+${formHeight}+"px;");
		//var temp =window.open(toUrl);
		gridSearch();
		$.dialog({
	        title: '${menuName}查看页面',
	        //content: 'url:<%=request.getContextPath() %>/auto!gotoView.action?formid=${requestScope.formid}&id='+id,-->
			content: 'url:'+ toUrl,
	        okVal: false,//确定按钮文字
	        cancelVal: false,//取消按钮文字
	        min: true, //是否显示最小化按钮
	        max: false,//是否显示最大化按钮
	        fixed: false,//开启静止定位
	        lock: true,//开启锁屏
	        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
	        time: null,//设置对话框显示时间
	        resize: true,//是否允许用户调节尺寸
	        drag: true,//是否允许用户拖动位置
	        cache: false,//是否缓存iframe方式加载的窗口内容页
	        zIndex:W==null?1976:W.$.dialog.setting.zIndex+1,
	        width: ${formWidth},
	        height: ${formHeight}
		});
	}
	function updateExcelMoBan(){
		var ids = $("#gridTable").jqGrid("getGridParam", "selarrrow");
			if (ids.length == 0) {   
			    alert("请先选择一条数据!");  
			    return false;  
				} 
			if(ids.length > 1){
				alert("只能选择一条数据！");
				return false;
			}
			var row = $("#gridTable").jqGrid("getRowData", ids);
			var id = row.ID;
			var toUrl = '<%=request.getContextPath() %>/filemodeAction!initFilemode.action?id='+id+'&opentype=edit&extendname=excel';
			//var temp =window.showModalDialog(toUrl,null,"dialogWidth=1280px;dialogHeight=750px;resizable=yes;scroll=yes");
			//document.location.href='auto!gotoList.action?formid=2521';
			window.open(toUrl,'newwindow','height=750,width=1280,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=yes,location=no, status=no') 
	}
	
	function updateYsjlForm(){
		var ids = $("#gridTable").jqGrid("getGridParam", "selarrrow");
			if (ids.length == 0) {   
			    alert("请先选择一条数据!");  
			    return false;  
				} 
			if(ids.length > 1){
				alert("只能选择一条数据！");
				return false;
			}
			var row = $("#gridTable").jqGrid("getRowData", ids);
			var id = row.ID;
			var toUrl = '<%=request.getContextPath() %>/filemodeAction!initYsjlForm.action?id='+id;
			var temp =window.showModalDialog(toUrl,null,"dialogWidth=500px;dialogHeight=300px;resizable=yes;scroll=yes");
			
	}
	
	
	function exportjstj(){//flag=0 为技术条件导入
		var result =window.showModalDialog("<%=basePath%>/wordmodel/select_excel_auto_form_list.jsp?flag=0&temp="+Math.round(Math.random()*10000),'',"dialogWidth=800px;dialogHeight=400px");
		if(result == 'success'){
			gridSearch();
		}
	}
	//导入设备方法
	function importSheBei(){//flag=1 为设备导入
		var result =window.showModalDialog("<%=basePath%>/wordmodel/select_excel_auto_form_list.jsp?flag=1&temp="+Math.round(Math.random()*10000),'',"dialogWidth=800px;dialogHeight=400px");
		if(result == 'success'){
			gridSearchSheBei();
		}
	}
	function exportjstjchu(){
		var ids = $("#gridTable").jqGrid("getGridParam", "selarrrow");
		$("#ids").val(ids);
		var T_JSTJ = encodeURIComponent(encodeURIComponent($('#T_JSTJ').val()));
		var T_JYXM = encodeURIComponent(encodeURIComponent($('#T_JYXM').val()));
		var T_CLPH = encodeURIComponent(encodeURIComponent($('#T_CLPH').val()));
		var T_JCS = encodeURIComponent(encodeURIComponent($('#T_JCS').val()));
		var params="&T_JSTJ="+T_JSTJ+"&T_JYXM="+T_JYXM+"&T_CLPH="+T_CLPH+"&T_JCS="+T_JCS;//+"&ids="+ids;//+"&ids="+ids;
		$("#params").val(params);
		document.forms['jstjForm'].submit();
		//window.location.href="filemodeAction!exportJiShuTiaoJian.action?params="+params;//+"&fieldsNames="+fieldsNames+"&params="+params
    } 
	function updateWordMoBan(){
		var ids = $("#gridTable").jqGrid("getGridParam", "selarrrow");
			if (ids.length == 0) {   
			    alert("请先选择一条数据!");  
			    return false;  
			} 
			if(ids.length > 1){
				alert("只能选择一条数据！");
				return false;
			}
			var row = $("#gridTable").jqGrid("getRowData", ids);
			var id = row.ID;
			var toUrl = '<%=request.getContextPath() %>/filemodeAction!initFilemode.action?id='+id+'&opentype=edit&extendname=doc';
			var temp =window.showModalDialog(toUrl,null,"dialogWidth=1280px;dialogHeight=750px;resizable=yes");
			document.location.href='auto!gotoList.action?formid=4101';
	
	}
	function lotSizeReadonly(){
		var ids = $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		 $.ajax({  
                   url : '<%=request.getContextPath()%>/filemodeAction!lotSizeReadonly.action?id='+ids,  
                   type : "post", 
                  // data : params,  
                   dataType : "json",  
                   cache : false,  
                 error : function(textStatus, errorThrown) {  
                   alert("系统ajax交互错误: " + textStatus.value);  
               },  
                success : function(data, textStatus) {  
                   if(data.ajaxResult=="success")
                   {
                      alert("设置成功!"); 
                	    window.close();
                	    gridSearch();
                    }else{
                     alert("设置失败,请重试!");
                   }   
                  }  
           });
		 
	}
	//查询
	function gridSearch(){
		 
		if('2221' == ${requestScope.formid}){
			var params = {  
				${requestScope.queryValue}
				columns : "${requestScope.columns}",
     			tableName:"${formnew.formEnName}",
     			queryColumn:"${requestScope.queryColumns}",
     			"formid":"${requestScope.formid}",
     			"byTableValue":"${requestScope.byTableValue}",
     			"byTableColumn":"${requestScope.byTableColumn}",
     			"sbtype":1
			};
		}else{
			var params = {  
				${requestScope.queryValue}
				columns : "${requestScope.columns}",
     			tableName:"${formnew.formEnName}",
     			queryColumn:"${requestScope.queryColumns}",
     			"formid":"${requestScope.formid}",
     			"byTableValue":"${requestScope.byTableValue}",
     			"byTableColumn":"${requestScope.byTableColumn}"
			};
		}
		 var postData = $("#gridTable").jqGrid("getGridParam", "postData");
		 $.extend(postData, params);
		jQuery("#gridTable").jqGrid('setGridParam',
		{
			url:'<%=request.getContextPath() %>/auto!queryAutoData.action?formid='+${requestScope.formid}+'&byTableValue=${requestScope.byTableValue}&byTableColumn=${requestScope.byTableColumn}&sbtype=${requestScope.sbtype}&columnguolvsql='+encodeURIComponent('${requestScope.columnguolvsql}')+'&temp='+Math.round(Math.random()*10000)
			
		}).trigger("reloadGrid", [{page:1}]); 
				
    } 
    //设备查询
    function gridSearchSheBei(){
		var params = {  
				${requestScope.queryValue}
				columns : "${requestScope.columns}",
     			tableName:"${formnew.formEnName}",
     			queryColumn:"${requestScope.queryColumns}",
     			"formid":"${requestScope.formid}",
     			"byTableValue":"${requestScope.byTableValue}",
     			"byTableColumn":"${requestScope.byTableColumn}",
     			sbtype:1
		};	
		 var postData = $("#gridTable").jqGrid("getGridParam", "postData");
		 $.extend(postData, params);
		jQuery("#gridTable").jqGrid('setGridParam',
		{
			url:'<%=request.getContextPath() %>/auto!queryAutoData.action?temp='+Math.round(Math.random()*10000)
		}).trigger("reloadGrid", [{page:1}]); 
    } 
    //按钮共用的方法
    //formid:表单id    formTitle：自定义按钮的名称       byTableColumn：关联表的外键
    function buttonOnclick(formid,formTitle,byTableColumn){
    	//alert(formid+"------------"+formTitle);
		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		if(ids.indexOf(",")!=-1){
			  alert("只能选择一条记录!");  
		        return false; 
		}
		var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
		var id = row.ID;
		var isChild=true;
		$.dialog({
	        title: formTitle,
	        //content: 'url:<%=request.getContextPath() %>/auto!gotoList.action?formid='+formid+'&isChild='+isChild+'&byTableValue='+id+'&byTableColumn='+byTableColumn,
	        content: 'url:<%=request.getContextPath() %>/auto!gotoList.action?formid='+formid+'&isChild='+isChild+'&byTableValue='+id+'&byTableColumn='+byTableColumn,
	        okVal: false,//确定按钮文字
	        zIndex: 2001,
	        cancelVal: false,//取消按钮文字
	        min: true, //是否显示最小化按钮
	        max: false,//是否显示最大化按钮
	        fixed: false,//开启静止定位
	        lock: true,//开启锁屏
	        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
	        time: null,//设置对话框显示时间
	        resize: true,//是否允许用户调节尺寸
	        drag: true,//是否允许用户拖动位置
	        cache: false,//是否缓存iframe方式加载的窗口内容页
	        zIndex:W==null?1976:W.$.dialog.setting.zIndex+1,
	        width: '1100px',
	        height: 600
		});
	}
	//合格证的标签管理中复制标签按钮
	function copyBianqiao()
	{
	  	var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		if(ids.indexOf(",")!=-1){
			  alert("只能选择一条记录!");  
		        return false; 
		}
		var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
	    //在合格证标签中添加新纪录
         $.ajax({  
             url : '<%=basePath%>/workflow/saveNewBiaoqian.action?id='+row.ID+'&num='+parseInt('${seqValues}'),  
             type : "post", 
             async: false,//取消异步提交 
             dataType : "json",  
             success : function(data, textStatus) {  
            if(data.ajaxResult=="success"){
                gridSearch();
                alert("复制标签成功!");
             }
             else{
               alert("复制标签失败!请重试!");
              }
             }  
         });
	
	}
	function updateMoBan(){
		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		if(ids.indexOf(",")!=-1){
			  alert("只能选择一条记录!");  
		        return false; 
		}
		var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
		var id = row.ID;
		$.dialog({
	        title: '修改信息',
	        content: 'url:<%=request.getContextPath() %>/auto!gotoList.action?mobanid='+id+'&formid=3041&byTableValue='+id+'&byTableColumn=MOBANID',
	        okVal: false,//确定按钮文字
	        cancelVal: false,//取消按钮文字
	        min: true, //是否显示最小化按钮
	        max: false,//是否显示最大化按钮
	        fixed: false,//开启静止定位
	        lock: true,//开启锁屏
	        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
	        time: null,//设置对话框显示时间
	        resize: true,//是否允许用户调节尺寸
	        drag: true,//是否允许用户拖动位置
	        cache: false,//是否缓存iframe方式加载的窗口内容页
	        width: '900px',
	        height: 470
		});
	}
	function tijiaoshenhe(){
		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		if(ids.indexOf(",")!=-1){
			  alert("只能选择一条记录!");  
		        return false; 
		}
		var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
		var id = row.ID;
		var state = row.SHENHESTATE;
		if(state=='审核中'){
			  alert("流程正在审核中，不能重复提交流程!");  
		        return false; 
		}else if(state=='审核通过'){
			alert("流程已审核通过，不能重复提交流程!");  
		        return false;
		}
		$.dialog({
	        title: '提交审核',
	        content: 'url:<%=request.getContextPath() %>/task/tasklist_new.jsp?flowid=<%=PubMethod.GetFlowid("flow.templetFlowId") %>&mainid='+id,
	        okVal: false,//确定按钮文字
	        cancelVal: false,//取消按钮文字
	        min: true, //是否显示最小化按钮
	        max: false,//是否显示最大化按钮
	        fixed: false,//开启静止定位
	        lock: true,//开启锁屏
	        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
	        time: null,//设置对话框显示时间
	        resize: true,//是否允许用户调节尺寸
	        drag: true,//是否允许用户拖动位置
	        cache: false,//是否缓存iframe方式加载的窗口内容页
	        width: '900px',
	        height: 470
		});
	}
	function chooseItem(){
		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		if(ids.indexOf(",")!=-1){
			alert("只能选择一条记录!");  
		    return false; 
		}
		var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
		var id = row.ID; 
		var obj = new Object();
		obj.mubanid = '<%=request.getParameter("mobanid")%>';
		obj.sampleid = id;
		var equipmentIds = window.showModalDialog("<%=basePath%>/task/choose_template_item.jsp?flag=${requestScope.flag}",obj,"dialogWidth=1060px;dialogHeight=550px");
	}
	//选择人员
	function selectperson(id)
	{
		var users = window.showModalDialog("<%=request.getContextPath() %>/user/chooseAllUser.jsp", window, "dialogWidth:1000px;status:no;dialogHeight:500px");
    	if (users != null) {
    		var userIds = [];
            var userNames = [];
            for(var i=0;i<users.length;i++){
                userIds.push(users[i]['userid']);
                userNames.push(users[i]['username']);
            }
            document.getElementById("user_"+id).value = userNames.join();
            //document.getElementById(id).value = userIds.join();
            document.getElementById(id).value = userNames.join();
    	}
	}
	//选择部门
	function selectdept(id)
	{
		var datas = window.showModalDialog("<%=basePath%>/resource/choose/choose_organizationIndex.jsp?temp="+Math.round(Math.random()*10000),'',"dialogWidth=900px;dialogHeight=550px");
		if(typeof(datas) == 'undefined'){
		}else{
			var json1 = eval('(' + datas + ')');
			 document.getElementById("dept_"+id).value = json1.ORG_NAME;
			 document.getElementById(id).value = json1.ORG_ID;
		}
	}
	//选择外键数据信息
	//参数信息：表明，关联列，显示列
	function selectData(id,tablename,colname,disname,cnname){
	    var fileColname ='hideFileName';
	    if(tablename=='DIC_STANDARD'){
	      fileColname = "YCLJS_GYYW";
	    }
		var datas = window.showModalDialog("<%=basePath%>/form/auto_choose_list.jsp?flag=0&tablename="+tablename+"&colname="+colname+"&disname="+disname+"&cnname="+escape(encodeURIComponent(cnname))+"&fileColname="+fileColname+"&temp="+Math.round(Math.random()*10000),'',"dialogWidth=500px;dialogHeight=500px");
		if(typeof(datas) == 'undefined'){
		}else{
			var json1 = eval('(' + datas + ')');
			 //document.getElementById("data_"+id).value = json1.NAME;			
			 //document.getElementById(id).value = json1.ID;
			 
			 //request.getParameter("data_"+id).value = json1.NAME;
			 //request.getParameter(id).value = json1.ID;
			 $("#data_"+id).val(json1.NAME);
			 $("#"+id).val(json1.ID);
			 
		}
	}
	//修改判定公式
	function editgongshi(){
	   var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		if(ids.indexOf(",")!=-1){
			  alert("只能选择一条记录!");  
		        return false; 
		}
		var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
		var id = row.ID;
		var toUrl = '<%=request.getContextPath() %>/auto!gotoUpdatepdgs.action?formid=${requestScope.formid}&id='+id+'&byTableValue=${requestScope.byTableValue}&byTableColumn=${requestScope.byTableColumn}';
		var temp =window.showModalDialog(toUrl,null,"dialogWidth=650px;dialogHeight=500px;");
		gridSearch();
	}
	
	function shebeipaicheng(){
		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		if(ids.indexOf(",")!=-1){
			  alert("只能选择一条记录!");  
		        return false; 
		}
		var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
		var id = row.ID;
		var temp =window.showModalDialog("<%=request.getContextPath() %>/visual/equipment_list.jsp?shebeiid="+id,null,"dialogWidth=1100px;dialogHeight=650px;");
	}
	
	function shiyongltj(){
		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		if(ids.indexOf(",")!=-1){
			  alert("只能选择一条记录!");  
		        return false; 
		}
		var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
		var id = row.ID;
		var temp =window.showModalDialog("<%=request.getContextPath() %>/visual/shiyongltj.jsp?shebeiid="+id,null,"dialogWidth=1100px;dialogHeight=650px;");
	}
	
	function addFZRItem(){
		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
			if (!ids) {
			    alert("请先选择记录!");  
			    return false;  
			}
			if(ids.indexOf(",")!=-1){
				  alert("只能选择一条记录!");  
			        return false; 
			}
			var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
			var id = row.ID;//获取选中行的id属性
			var toUrl = '<%=request.getContextPath() %>/view/test_ability_add_users_.jsp?ids='+id+'&temp='+Math.round(Math.random()*10000);
//			var temp =window.showModalDialog(toUrl,null,"dialogWidth="+900+"px;dialogHeight="+600+"px;");
			$.dialog({
		        title: '添加台架负责人',
		        content: 'url:'+ toUrl,
		        okVal: false,//确定按钮文字
		        cancelVal: false,//取消按钮文字
		        min: true, //是否显示最小化按钮
		        max: false,//是否显示最大化按钮
		        fixed: false,//开启静止定位
		        lock: true,//开启锁屏
		        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
		        time: null,//设置对话框显示时间
		        resize: true,//是否允许用户调节尺寸
		        drag: true,//是否允许用户拖动位置
		        cache: false,//是否缓存iframe方式加载的窗口内容页
		        width: '500px',
		        height: 500
			});
	}
	
	//数据列表
	function analysisList(){
		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		if(ids.indexOf(",")!=-1){
			  alert("只能选择一条记录!");  
		        return false; 
		}
		var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
		var filemodeid = row.ID;
		$.ajax({
			type: "POST",
			async: false,//取消异步提交
			url: 'auto!getFilemodeinfo.action?filemodeid='+filemodeid,
			dataType: "json",
			success : function(data, textStatus) {  
				if(data.result=='success'){
					$.dialog({
				        title: '数据信息',
				        id:'cerify',
				        content: 'url:auto!gotoListForAnalysis.action?filemodeid='+filemodeid+'&formid='+data.baseinfoid+'&temp='+Math.round(Math.random()*10000),
				        okVal: false,//确定按钮文字
				        cancelVal: false,//取消按钮文字
				        min: true, //是否显示最小化按钮
				        max: false,//是否显示最大化按钮
				        fixed: false,//开启静止定位
				        lock: true,//开启锁屏
				        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
				        time: null,//设置对话框显示时间
				        resize: true,//是否允许用户调节尺寸
				        drag: true,//是否允许用户拖动位置
				        cache: false,//是否缓存iframe方式加载的窗口内容页
				        width: '1030px',
				        height: '570px'
					});												
				}else{
					alert("表单显示错误！")
				}
			}
		});
	}
	
	
	//查看数据
	function viewList(){
		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		if(ids.indexOf(",")!=-1){
			  alert("只能选择一条记录!");  
		        return false; 
		}
		var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
		var id = row.ID;
		$.ajax({
					type: "POST",
					async: false,//取消异步提交
					url: '<%=request.getContextPath() %>/auto!getForminfoBymodeid.action?modeid='+id,
					dataType: "json",
					success : function(data, textStatus) {  
						$.dialog({
					        title: '数据信息',
					        id:'cerify',
					        content: 'url:auto!gotoList.action?formid='+data.datainfoid+'&temp='+Math.round(Math.random()*10000),
					        okVal: false,//确定按钮文字
					        cancelVal: false,//取消按钮文字
					        min: true, //是否显示最小化按钮
					        max: false,//是否显示最大化按钮
					        fixed: false,//开启静止定位
					        lock: true,//开启锁屏
					        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
					        time: null,//设置对话框显示时间
					        resize: true,//是否允许用户调节尺寸
					        drag: true,//是否允许用户拖动位置
					        cache: false,//是否缓存iframe方式加载的窗口内容页
					        zIndex:W==null?1976:W.$.dialog.setting.zIndex+1,
					        width: '1030px',
					        height: '570px'
						});
					}
		});
	}

    //导入
    function impExcel(){
    	var formId = jQuery("#formId").val();
		var type="eqAction!importPersonData.action";
		var sURL="<%=request.getContextPath() %>/view/file_importecxel.jsp?formId="+formId+"&type="+type;
	  	window.showModalDialog(sURL,"","dialogWidth=400px;dialogHeight=200px;dialogLeft:400xp;dialogTop:100xp");
	   	gridSearch();
	}
	
	//导出excel
    function exportExcel(){
            var formId = jQuery("#formId").val();
            window.location.href="eqAction!exportExcel.action?formId="+formId; 
    }
    
    function addTree(tablename,tablecnname){
    	var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
    	if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		window.parent.showTree();
		var newNode = [{name:tablecnname,id:"auto_"+tablename, open:true}];
		window.parent.addAutoroot(tablename,tablecnname);
		var arrayIds = ids.split(',');
    	for(var i=0;i<arrayIds.length;i++){
    		var row = jQuery("#gridTable").jqGrid('getRowData',arrayIds[i]);//获取选中行.
    		var obj = new Object();
    		obj.marktype = '${marktype}';
    		if('${bjingdu}'!='null'&&'${bweidu}'!='null')
    		{
    			obj.bjingdu = row.${bjingdu};
    			obj.bweidu = row.${bweidu};
    		}
    		
    		if ('${ejingdu}'!='null'){
    			obj.ejingdu = row.${ejingdu};
    			obj.eweidu = row.${eweidu};
    		}
    		window.parent.addAutoleaf(tablename,row.ID,row.${mapmark},obj)
    	}
    }
	
	</script>	
	</head>
	<body>
	<form id="jstjForm" name="jstjForm" action="filemodeAction!exportJiShuTiaoJian.action" method="post" >
		<input id="ids" type='hidden' name="ids" />
		<input id="params" type='hidden' name="params"/>
	</form>
	<form action="" method="post" >
		 <input type="hidden" id="formId" name="formId" value="${requestScope.formid}"/>
		 	 <table style='width:100%'>
		 	 	<tr>
		 	 		${queryContent }
			   	</td>
		 	 	</tr>
		 	 </table>
		     
			<table style="width: 100%;" class="tableCont">
			<tr>
				<td colspan="4">
					<table id="gridTable"></table>
					<div id="gridPager"></div>
				</td>
			</tr>
		</table>
		</form>
	</body>
</html>
